#include "stdafx.h"
#include "ThreadImpl.h"
#include "platform.h"
#include "TaskQueue.h"

ThreadImpl::ThreadImpl() :
id_(0),
handle_(0),
complete_task_cnt_(0),
task_queue_(NULL)
{
}

ThreadImpl::~ThreadImpl()
{
}

bool ThreadImpl::init(TaskQueue *task_queue)
{
	if(!task_queue)
		return false;
	task_queue_ = task_queue;
	return start_thread(NULL);
}

bool ThreadImpl::start_thread(void *param)
{
	return true;
}

ThreadImpl * ThreadImpl::create(TaskQueue *task_queue)
{
	ThreadImpl * inst = new ThreadImpl();
	if(inst)
	{
		if(!inst->init(task_queue))
		{
			inst->destroy();
			inst = NULL;
		}
	}
	return inst;
}


uint32_t ThreadImpl::get_handle() const
{
	return handle_;
}

uint32_t ThreadImpl::get_id() const
{
	return id_;
}

uint32_t ThreadImpl::get_complete() const
{
	return complete_task_cnt_;
}

Thread::ThreadStatus ThreadImpl::get_status() const
{
	return status_;
}

Thread::ThreadStatus ThreadImpl::start()
{
	ThreadStatus prev = status_;
	return prev;
}

Thread::ThreadStatus ThreadImpl::suspend()
{
	ThreadStatus prev = status_;
	return prev;
}

void ThreadImpl::destroy()
{
	delete this;
}

TaskQueue * ThreadImpl::get_task_queue() const
{
	return task_queue_;
}

void ThreadImpl::set_task_queue(TaskQueue *task_queue)
{
	task_queue_ = task_queue;
}